﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using University.Workshop.Presenters.Square.Register;

namespace University.Workshop.Presentation.Square.Register
{
    /// <summary>
    /// Interaction logic for PageSecondStepRegisterSquare.xaml
    /// </summary>
    public partial class PageSecondStepRegisterSquare : Page,ISecondStepForRegisterSquare
    {
        private PresenterRegisterNewSquare pInternal;
        private PresenterSecondStepForRegisterSquare pSecondStepForRegisterSquare;
        public PageSecondStepRegisterSquare(Presenters.Square.Register.PresenterRegisterNewSquare pExternal)
        {
            InitializeComponent();

            pInternal = pExternal;
            pSecondStepForRegisterSquare = new PresenterSecondStepForRegisterSquare(this);
        }

        public ICollection<Model.Allotment> Allotments
        {
            get
            {
                if (AllotmentsDtgv.ItemsSource == null) 
                return new List<Model.Allotment>();
                else
                return (List<Model.Allotment>)AllotmentsDtgv.ItemsSource;
            }
            set{
                AllotmentsDtgv.ItemsSource = null;
                AllotmentsDtgv.ItemsSource = value;
            }
        }

        public string NameNewAllotment
        {
            get
            { return AllotmentNameTxBx.Text; }
            set { AllotmentNameTxBx.Text = value; }
        }

        public Model.Allotment AllotmentSelected
        {
            get { return (Model.Allotment)AllotmentsDtgv.SelectedItem; }
            set { throw new NotImplementedException(); }
        }

        public Model.Square SquareToRegister
        {
            get;
            set;
        }

        public ICollection<Model.Allotment> AllotmentsToRegister
        {
            get;
            set;
        }

        public void Update()
        {
            pSecondStepForRegisterSquare.UpdateData();
        }

        public string UbicationCroquisSquareToRegister
        {
            get;
            set;
        }

        public string SystemMessage
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                pInternal.NotifySystemMessage(value);
            }
        }

        public string ErrorMessage
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                pInternal.NotifyErrorMessage(value);
            }
        }


        public void ChargeDataToBasic()
        {
            pSecondStepForRegisterSquare.ChargeDataMedicineProduct();
        }

        public void GoNextPage()
        {

        }

        public void GoBackPage()
        {
            pInternal.GoStepOne();
        }

        private void AddAllotmentbtn_Click(object sender, RoutedEventArgs e)
        {
            pSecondStepForRegisterSquare.AddAllotmentToList();
        }

        private void DeleteAllotmentDelete_Click(object sender, RoutedEventArgs e)
        {
            pSecondStepForRegisterSquare.DeleteAllotmentInList();
        }
    }
}
